project(Python-For-Matlab-Users-Tutorial)


#
#  Find the tex files in this directory
#  These are all assumed to be dependencies of the ouput PDF
#
file(GLOB_RECURSE TEX_FILES *.tex)

#
# Define the search path for all pdflatex input files
#
set(TEXINPUTS ".:${Python-For-Matlab-Users-Tutorial_SOURCE_DIR}:${FIGURES_DIR}:${Python-For-Matlab-Users_SOURCE_DIR}:")

#
# This adds a custom target that generates the output document
# This target depends on the list tex files, python files, and figures
#
add_custom_command(OUTPUT tutorial.pdf
  COMMAND ${CMAKE_COMMAND}
    -D SOURCE_TEX:FILEPATH=${Python-For-Matlab-Users-Tutorial_SOURCE_DIR}/tutorial.tex
    -D TEXINPUTS:STRING=${TEXINPUTS}
    -D OUTPUT_DIR:FILEPATH=${Python-For-Matlab-Users-Tutorial_BINARY_DIR}
    -P ${Python-For-Matlab-Users_SOURCE_DIR}/CMake/RunPDFLatex.cmake
  DEPENDS ${FIGURE_FILES} ${PYTHON_FILES} ${TEX_FILES}
  WORKING_DIRECTORY ${Python-For-Matlab-Users-Tutorial_BINARY_DIR}
  )

add_custom_target(TutorialPresentation ALL DEPENDS tutorial.pdf)

